#ifndef _TRIM_H
#define _TRIM_H
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
inline   std::string&   ltrim(std::string   &ss)
{
    std::string::iterator   p = find_if(ss.begin(), ss.end(), std::not1(std::ptr_fun(::isspace)));
    ss.erase(ss.begin(), p);
    return   ss;
}

inline   std::string&   rtrim(std::string   &ss)
{
    std::string::reverse_iterator   p = find_if(ss.rbegin(), ss.rend(), std::not1(std::ptr_fun(::isspace)));
    ss.erase(p.base(), ss.end());
    return   ss;
}
inline   std::string&   trim(std::string   &st)
{
    ltrim(rtrim(st));
    return   st;
}
std::vector<std::string> inline split(const std::string & source, const std::string & delimiter)
{
    std::vector<std::string> result;
    std::string input = source;
    std::string::size_type index = input.find_first_of(delimiter);

    while (index != std::string::npos)
    {
        std::string substr = input.substr(0, index);
        input.erase(0, index + delimiter.size());
        result.push_back(substr);
        index = input.find_first_of(delimiter);
    }

    result.push_back(input);
    return result;
}
#endif

